package com.solo.system.model.menu.req;

import com.solo.common.orm.core.query.anno.Query;
import com.solo.common.orm.core.query.anno.QueryTable;
import com.solo.common.orm.core.query.enums.Connector;
import com.solo.common.orm.core.query.enums.QueryMode;
import com.solo.system.api.entity.table.SysI18nTypeDataTableDef;
import com.solo.system.api.entity.table.SysMenuTableDef;
import lombok.Data;

/**
 * 菜单查询对象 req
 * @author 十一
 * @since 2023-11-14 14:13
 * 人生若只如初见，何事秋风悲画扇
 **/
@Data
@QueryTable(table = SysMenuTableDef.class)
public class MenuQueryReq {

    /**
     * 父级id
     */
    @Query
    private Long parentId;

    /**
     * 菜单类型[M:菜单 B:按钮 D:目录]
     */
    @Query
    private String type;

    /**
     * 菜单名称
     */
    @Query(group = 1, mode = QueryMode.LIKE)
    private String name;

    /**
     * 翻译
     */
    @Query(table = SysI18nTypeDataTableDef.class,
            group = 1,
            mode = QueryMode.LIKE,
            connector = Connector.OR)
    private String translate;

    /**
     * 设置菜单名称，并同时设置翻译字段的值
     * @param name 菜单名称
     */
    public void setName(String name) {
        this.name = name;
        this.translate = name;
    }

}
